home *** CD-ROM | disk | FTP | other *** search
/ SGI Cosmo Software 1997 May / SGI Cosmo Software 1997 May.iso / dist / dmedia_eoe.idb / usr / include / sys / hdsp.h.z / hdsp.h
C/C++ Source or Header  |  1997-05-23  |  11KB  |  289 lines

  1. #ifndef    __HDSP_H__
  2. #define    __HDSP_H__ 
  3. /**************************************************************************
  4.  *                                      *
  5.  *          Copyright (C) 1988, Silicon Graphics, Inc.          *
  6.  *                                      *
  7.  *  These coded instructions, statements, and computer programs  contain  *
  8.  *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
  9.  *  are protected by Federal copyright law.  They  may  not be disclosed  *
  10.  *  to  third  parties  or copied or duplicated in any form, in whole or  *
  11.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  12.  *                                      *
  13.  **************************************************************************/
  14. #ident "$Revision: 1.39 $"
  15.  
  16. /**************************************************************************
  17.  *
  18.  *  hdsp.h - High fidelity DSP device driver programmer visible structs.
  19.  *
  20.  **************************************************************************/
  21.  
  22. /*
  23.  * ring buffer header
  24.  */
  25. typedef struct rbheader_s 
  26. {
  27.     long head;             /* index of buffer head location */   
  28.     long tail;            /* index of buffer tail location */
  29.     long intreq;                /* */
  30.     long fillpt;                /* buffer fill point             */
  31. }rbheader_t;
  32.  
  33. #define RBHEADER_SIZE (sizeof(rbheader_t)/sizeof(long))
  34.  
  35. /* 
  36.  * ioctl cases
  37.  */
  38. #define HDSP_RESET        0
  39. #define HDSP_ACTIVATE        1
  40. #define HDSP_FIND_MINOR        2
  41. #define HDSP_ACQUIRE_AUDIO_RB    3
  42. #define HDSP_SET_AUDIO_PARMS    4
  43. #define HDSP_GET_AUDIO_PARMS    5
  44. #define HDSP_GET_HRBSTATUS      6
  45. #define HDSP_SET_HRBSTATUS      7
  46. #define HDSP_SET_RB_INFO    8
  47. #define HDSP_GET_ALL_RB_INFO    9
  48. #define HDSP_SET_RB_TYPE    10
  49. #define HDSP_GET_RB_MSC        11
  50. #define HDSP_FLUSH        12    
  51. #define HDSP_PORTCTRL        13
  52. #define HDSP_QUERYPARAMS    14
  53. #define HDSP_GET_MINMAX        15
  54. #define HDSP_GET_NAME        16
  55. #define HDSP_GET_DEFAULT    17
  56. #define HDSP_ACQUIRE_DIRECT_AUDIO_RB    18
  57. #define HDSP_GET_RB_USTMSC    19
  58.  
  59. #ifndef HRB_STRLEN
  60. #define HRB_STRLEN 20        /* max length of HRB/port name */
  61. #endif
  62.  
  63. /* 
  64.  * arg struct for HDSP_ACQUIRE_AUDIO_RB ioctl
  65.  */
  66. typedef struct hdsp_acquireaudiorb_s 
  67. {
  68.     int nlocs;        /* Number of locations in the user's virtual space. */
  69.     char direction;    /* TOMIPS or FROMMIPS */
  70. } hdsp_acquireaudiorb_t;
  71.  
  72. /* 
  73.  * arg struct for HDSP_SET_RB_INFO ioctl
  74.  */
  75. typedef struct hdsp_setrbinfo_s 
  76. {
  77.     char name[HRB_STRLEN];    /* name of HRB/port */
  78.     int version;        /* AL version number */
  79. } hdsp_setrbinfo_t;
  80.  
  81. /* 
  82.  * arg struct for HDSP_GET_RBINFO ioctl
  83.  */
  84. typedef struct hdsp_getrbinfo_s
  85. {
  86.     char name[HRB_STRLEN];    /* name of HRB/port */
  87.     int pid;            /* pid of process associated with port */
  88.     int type;            /* TOMIPS or FROMMIPS */
  89.     int rbid;            /* internal id associated with RB */
  90.     int version;        /* AL version */
  91.     int errcnt;            /* error count for the RB */
  92.     int nchans;            /* number of channels in RB */
  93.     int head;            /* head of RB */
  94.     int tail;            /* tail of RB */
  95.     int nlocs;            /* number of locations in RB */
  96. } hdsp_getrbinfo_t;
  97.  
  98. /*
  99.  * arg struct for HDSP_GET_RBSTATUS and HDSP_SET_RBSTATUS
  100.  */
  101. typedef struct hdsp_rbstatus_s 
  102. {
  103.     long error;          /* ring buffer error count */
  104.     long type;           /* the type of error */
  105.     long length;         /* the length of the error (in samples) */
  106.     long location[2];    /* location (in samples) of the beginning of */
  107.                          /* the error. location[0] is the low 24 bits, and */
  108.                          /* location[1] is the high 24 bits of a 48-bit count*/
  109. } hdsp_rbstatus_t;
  110.  
  111. typedef struct hdsp_rbmsc_s
  112. {
  113.     /* These are taken atomically */
  114.     unsigned long long msc;    /* MSC at kernel side of ring-buffer */
  115.     unsigned int head, tail;    /* HRB head and tail values */
  116.     unsigned long long ust;    /* Unadjusted System Time */
  117. } hdsp_rbmsc_t;
  118.  
  119. /* 
  120.  * ioctl parameter subcodes
  121.  * same subcodes used for both set and get of parameters 
  122.  * buffer looks like an array of longs: [len, subcode,value, subcode, 
  123.  * value, ...] 
  124.  * values are read on sets and filled in on gets 
  125.  *
  126.  * make sure corresponding parameters in audio.h and hdsp.h agree
  127.  *
  128.  * IF YOU ADD ANY PARAMETERS, YOU MAY NEED TO UPDATE MAX_AUDIO_PARMS_LEN
  129.  * YOU MAY ALSO NEED TO UPDATE AL_MAX_PBUFSIZE, in audio.h. These two
  130.  * parameters should be the same, and large enough to hold all the
  131.  * parms and associated values.
  132.  */
  133. #define HDSP_MAX_AUDIO_PARMS_LEN    64
  134. #define HDSP_INPUT_SOURCE        0
  135. #define HDSP_LEFT_INPUT_ATTEN        1
  136. #define HDSP_RIGHT_INPUT_ATTEN        2
  137. #define HDSP_LEFT1_INPUT_ATTEN        1 /* Same as HDSP_LEFT_INPUT_ATTEN */
  138. #define HDSP_RIGHT1_INPUT_ATTEN        2 /* Same as HDSP_LEFT_INPUT_ATTEN */
  139. #define HDSP_INPUT_RATE            3
  140. #define HDSP_OUTPUT_RATE        4
  141. #define HDSP_LEFT_SPEAKER_GAIN        5
  142. #define HDSP_RIGHT_SPEAKER_GAIN        6
  143. #define HDSP_INPUT_RBCOUNT        7
  144. #define HDSP_OUTPUT_RBCOUNT        8
  145. #define HDSP_UNUSED_RBCOUNT        9
  146. #define HDSP_MONITOR_CTL                12
  147. #define HDSP_LEFT_MONITOR_ATTEN         13
  148. #define HDSP_RIGHT_MONITOR_ATTEN        14
  149. #define HDSP_CHANNEL_MODE            15
  150. #define HDSP_SPEAKER_MUTE_CTL        16
  151. #define HDSP_MIC_MODE            17
  152. #define HDSP_LEFT2_INPUT_ATTEN        18
  153. #define HDSP_RIGHT2_INPUT_ATTEN        19
  154. #define HDSP_DIGITAL_INPUT_RATE        20
  155. #define HDSP_LOCK_STATE            21
  156.  
  157. #define HDSP_RANGE_VALUE 2
  158. #define HDSP_ENUM_VALUE  1
  159.  
  160. /*
  161.  * support for dormant ports
  162.  */
  163. #define HDSP_DEACTIVATE_PORT    0
  164. #define HDSP_ACTIVATE_PORT    1
  165.  
  166. /*
  167.  * current ring-buffer types
  168.  */
  169. #define HDSP_MONO        1
  170. #define HDSP_STEREO        2
  171. #define HDSP_4CHANNEL        4
  172.  
  173. /* 
  174.  * available rates, in Hz, 44100 == 44.1KHz, 
  175.  *            5333_33 == 5.33333 KHz etc 
  176.  * The _ALT entries are different hardware 
  177.  *    configurations that achieve the same rate 
  178.  * NOTE: these rates are implementation dependent 
  179.  *    44.1, and 48 are the least likely to change 
  180.  *    You have been warned 
  181.  */
  182. #define HDSP_C_RATE(x)    ((x)<<1)
  183. #define HDSP_M_RATE(x)    ((x)<<2)
  184. #define HDSP_S_RATE(x)    ((x)<<4)
  185.  
  186. #define HDSP_RATE_48000        (HDSP_M_RATE(0)|HDSP_C_RATE(0)|HDSP_S_RATE(0))
  187. #define HDSP_RATE_44100        (HDSP_M_RATE(1)|HDSP_C_RATE(0)|HDSP_S_RATE(0))
  188. #define HDSP_RATE_32000        (HDSP_M_RATE(0)|HDSP_C_RATE(1)|HDSP_S_RATE(0))
  189. #define HDSP_RATE_29400        (HDSP_M_RATE(1)|HDSP_C_RATE(1)|HDSP_S_RATE(0))
  190. #define HDSP_RATE_24000        (HDSP_M_RATE(0)|HDSP_C_RATE(0)|HDSP_S_RATE(1))
  191. #define HDSP_RATE_22050        (HDSP_M_RATE(1)|HDSP_C_RATE(0)|HDSP_S_RATE(1))
  192. #define HDSP_RATE_16000        (HDSP_M_RATE(0)|HDSP_C_RATE(0)|HDSP_S_RATE(2))
  193. #define HDSP_RATE_16000_ALT    (HDSP_M_RATE(0)|HDSP_C_RATE(1)|HDSP_S_RATE(1))
  194. #define HDSP_RATE_14700        (HDSP_M_RATE(1)|HDSP_C_RATE(0)|HDSP_S_RATE(2))
  195. #define HDSP_RATE_14700_ALT    (HDSP_M_RATE(1)|HDSP_C_RATE(1)|HDSP_S_RATE(1))
  196. #define HDSP_RATE_12000        (HDSP_M_RATE(0)|HDSP_C_RATE(0)|HDSP_S_RATE(3))
  197. #define HDSP_RATE_11025        (HDSP_M_RATE(1)|HDSP_C_RATE(0)|HDSP_S_RATE(3))
  198. #define HDSP_RATE_10666_7    (HDSP_M_RATE(0)|HDSP_C_RATE(1)|HDSP_S_RATE(2))
  199. #define HDSP_RATE_9800        (HDSP_M_RATE(1)|HDSP_C_RATE(1)|HDSP_S_RATE(2))
  200. #define HDSP_RATE_9600        (HDSP_M_RATE(0)|HDSP_C_RATE(0)|HDSP_S_RATE(4))
  201. #define HDSP_RATE_8820        (HDSP_M_RATE(1)|HDSP_C_RATE(0)|HDSP_S_RATE(4))
  202. #define HDSP_RATE_8000        (HDSP_M_RATE(0)|HDSP_C_RATE(0)|HDSP_S_RATE(5))
  203. #define HDSP_RATE_8000_ALT    (HDSP_M_RATE(0)|HDSP_C_RATE(1)|HDSP_S_RATE(3))
  204. #define HDSP_RATE_7350        (HDSP_M_RATE(1)|HDSP_C_RATE(0)|HDSP_S_RATE(5))
  205. #define HDSP_RATE_7350_ALT    (HDSP_M_RATE(1)|HDSP_C_RATE(1)|HDSP_S_RATE(3))
  206. #define HDSP_RATE_6857_14    (HDSP_M_RATE(0)|HDSP_C_RATE(0)|HDSP_S_RATE(6))
  207. #define HDSP_RATE_6400        (HDSP_M_RATE(0)|HDSP_C_RATE(1)|HDSP_S_RATE(4))
  208. #define HDSP_RATE_6300        (HDSP_M_RATE(1)|HDSP_C_RATE(0)|HDSP_S_RATE(6))
  209. #define HDSP_RATE_6000        (HDSP_M_RATE(0)|HDSP_C_RATE(0)|HDSP_S_RATE(7))
  210. #define HDSP_RATE_5880        (HDSP_M_RATE(1)|HDSP_C_RATE(1)|HDSP_S_RATE(4))
  211. #define HDSP_RATE_5512_5    (HDSP_M_RATE(1)|HDSP_C_RATE(0)|HDSP_S_RATE(7))
  212. #define HDSP_RATE_5333_33    (HDSP_M_RATE(0)|HDSP_C_RATE(1)|HDSP_S_RATE(5))
  213. #define HDSP_RATE_4900        (HDSP_M_RATE(1)|HDSP_C_RATE(1)|HDSP_S_RATE(5))
  214. #define HDSP_RATE_4571_43    (HDSP_M_RATE(0)|HDSP_C_RATE(1)|HDSP_S_RATE(6))
  215. #define HDSP_RATE_4200        (HDSP_M_RATE(1)|HDSP_C_RATE(1)|HDSP_S_RATE(6))
  216. #define HDSP_RATE_4000        (HDSP_M_RATE(0)|HDSP_C_RATE(1)|HDSP_S_RATE(7))
  217. #define HDSP_RATE_3675        (HDSP_M_RATE(1)|HDSP_C_RATE(1)|HDSP_S_RATE(7))
  218. /* 
  219.  * these set the rate to be the AES input rate divided by n, n = 1..8 
  220.  */
  221. #define HDSP_RATE_AES_1        (HDSP_M_RATE(3)|HDSP_C_RATE(0)|HDSP_S_RATE(0))
  222. #define HDSP_RATE_AES_2        (HDSP_M_RATE(3)|HDSP_C_RATE(0)|HDSP_S_RATE(1))
  223. #define HDSP_RATE_AES_3        (HDSP_M_RATE(3)|HDSP_C_RATE(0)|HDSP_S_RATE(2))
  224. #define HDSP_RATE_AES_4        (HDSP_M_RATE(3)|HDSP_C_RATE(0)|HDSP_S_RATE(3))
  225. #define HDSP_RATE_AES_5        (HDSP_M_RATE(3)|HDSP_C_RATE(0)|HDSP_S_RATE(4))
  226. #define HDSP_RATE_AES_6        (HDSP_M_RATE(3)|HDSP_C_RATE(0)|HDSP_S_RATE(5))
  227. #define HDSP_RATE_AES_7        (HDSP_M_RATE(3)|HDSP_C_RATE(0)|HDSP_S_RATE(6))
  228. #define HDSP_RATE_AES_8        (HDSP_M_RATE(3)|HDSP_C_RATE(0)|HDSP_S_RATE(7))
  229. /* 
  230.  * as above with a scale factor of s == 2/3 
  231.  */
  232. #define HDSP_RATE_AES_1s    (HDSP_M_RATE(3)|HDSP_C_RATE(1)|HDSP_S_RATE(0))
  233. #define HDSP_RATE_AES_2s    (HDSP_M_RATE(3)|HDSP_C_RATE(1)|HDSP_S_RATE(1))
  234. #define HDSP_RATE_AES_3s    (HDSP_M_RATE(3)|HDSP_C_RATE(1)|HDSP_S_RATE(2))
  235. #define HDSP_RATE_AES_4s    (HDSP_M_RATE(3)|HDSP_C_RATE(1)|HDSP_S_RATE(3))
  236. #define HDSP_RATE_AES_5s    (HDSP_M_RATE(3)|HDSP_C_RATE(1)|HDSP_S_RATE(4))
  237. #define HDSP_RATE_AES_6s    (HDSP_M_RATE(3)|HDSP_C_RATE(1)|HDSP_S_RATE(5))
  238. #define HDSP_RATE_AES_7s    (HDSP_M_RATE(3)|HDSP_C_RATE(1)|HDSP_S_RATE(6))
  239. #define HDSP_RATE_AES_8s    (HDSP_M_RATE(3)|HDSP_C_RATE(1)|HDSP_S_RATE(7))
  240.  
  241. #define HDSP_RATE_INPUTRATE         1   /* output rate tracks input rate */
  242. #define HDSP_RATE_UNDEFINED       (-1)  /* rate read is not defined by spec */
  243. #define HDSP_RATE_NO_DIGITAL_INPUT (-2)  /* AESRX PLL not yet locked.*/
  244. #define HDSP_RATE_UNACQUIRED       (-3)  /* PLL locked but rate not read yet */
  245.  
  246. /*
  247.  * Definition of some AES rate bits
  248.  */
  249.  
  250. #define HDSP_NONAUDIO_CONSUMER_RATE_44100 0
  251. #define HDSP_NONAUDIO_CONSUMER_RATE_UNDEFINED 1
  252. #define HDSP_NONAUDIO_CONSUMER_RATE_48000 2
  253. #define HDSP_NONAUDIO_CONSUMER_RATE_32000 3
  254.  
  255. /* 
  256.  * These are the available input sources 
  257.  */
  258. #define HDSP_INPUT_LINE        0    /* Line In Jack                       */
  259. #define HDSP_INPUT_MIC        1    /* Microphone Jack                    */
  260. #define HDSP_INPUT_DIGITAL    2    /* Digital I/O Jack                   */
  261.  
  262. /* 
  263.  * The following defines indicate the type of a host ring buffer. 
  264.  */
  265. #define HRB_TOMIPS    0        /*data transfer to mips               */
  266. #define HRB_FROMMIPS    1        /*data transfer from mips             */
  267. #define HRB_FOLDED    2         /*dsp (24b,24b) pair <-> mips 32b word*/
  268. #define HRB_UNFOLDED    0        /*dsp 24b word <-> mips 32b word      */
  269. #define HRB_EXTEND    4        /*sign extension                      */
  270. #define HRB_NOEXTEND    0        /*no sign extension                   */
  271. #ifdef _KERNEL
  272. #define HRB_USERSPACE    8        /*memory mapped to user space         */
  273. #define HRB_KERNELSPACE    0        /*memory mapped to kernel space       */
  274. #define HRB_SPLIT    0x10        /*rb has split header/buffer           */
  275. #define HRB_NODEFER    0x20        /*don't defer update of head/tail ptr */
  276. #define HRB_MASTER    0x40        /*ring buffer is a rate master  */
  277. #define HRB_DIRECT    0x80        /*direct rb*/
  278. #define HRB_SERIAL    0        /*serial access rb*/
  279. #define HRB_DORMANT    0x100        /*dormant RB */
  280. #define HRB_NOTALLOCED    0x200        /* RB mem not alloced by kerncreate */
  281. #endif /*_KERNEL*/
  282.  
  283. /*
  284.  * maximum ring buffer length in bytes
  285.  */
  286. #define MAXRBLEN (4096*256)
  287.  
  288. #endif /* __HDSP_H__ */
  289.